const http = require("http");

const server = http.createServer();

const qs = require('querystring');
server.on("request", (req, res) => {
    if (req.url === "/") {
        console.log(req.header.cookie);
        console.log(req.header)

        var cookie = qs.parse(req.header.cookie, ";");
        console.log(cookie);
        if (cookie.isvisit === "yes") {
            res.writeHeader(200, {
                "Content-Type": "text/html;charset=utf8"
            })
            res.end("抽奖成功,获得白龙吟")
        } else {
            res.writeHeader(200, {
                "Content-Type": "text/html;charset=utf8"
            })
            res.end("你已经抽过奖了")
        }
    }
})

server.listen(3004, () => {
    console.log("server running at http://localhost:3004");
})